package com.comparison;

import java.util.Comparator;

public class Person2 implements Comparator<Person2>{
	private String name;
	private int age;
	
	public Person2(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public int compare(Person2 o1, Person2 o2) {
		if(o1 == null || o2 == null ) {
			throw new NullPointerException();
		} else if(o1.getAge() > o2.getAge()) {
			return 1;
		} else if(o1.getAge() < o2.getAge()) {
			return -1;
		}
		return 0;
	}
}
